<?php

class AdApp extends MallbaseApp
{

	function index()
	{
		$db=&db();
		$list=array();
		$list1=array();
		$list2=array();
		$sql="select ad_tid,pic,title,type,outkey,url from cw_ad where is_show=1 and page='index' and position='center' order by sort_order limit 0,2";
		$adlist=$db->getAll($sql);
		if($adlist){
			foreach ($adlist as $k=>$v){
				if($v['type']=='article'){
					$v['url']=site_url().'/index.php?app=article&act=view&article_id='.$v['outkey'];
				}
				if($v['type']!='article'&&$v['type']!='url'){
					$v['url']='';
				}
				$list[]=$v;
			}
		}

		$sql="select ad_tid,pic,title,type,outkey,url from cw_ad where is_show=1 and page='index' and position='center' order by sort_order limit 2,3";
		$adlist1=$db->getAll($sql);
		if($adlist1){
			foreach ($adlist1 as $k=>$v){
				if($v['type']=='article'){
					$v['url']=site_url().'/index.php?app=article&act=view&article_id='.$v['outkey'];
				}
				if($v['type']!='article'&&$v['type']!='url'){
					$v['url']='';
				}
				$list1[]=$v;
			}
		}

		$sql="select ad_tid,pic,title,type,outkey,url from cw_ad where is_show=1 and page='index' and position='center' order by sort_order limit 5,3";
		$adlist2=$db->getAll($sql);
		if($adlist2){
			foreach ($adlist2 as $k=>$v){
				if($v['type']=='article'){
					$v['url']=site_url().'/index.php?app=article&act=view&article_id='.$v['outkey'];
				}
				if($v['type']!='article'&&$v['type']!='url'){
					$v['url']='';
				}
				$list2[]=$v;
			}
		}
		$this->assign('list',$list);
		$this->assign('list1',$list1);
		$this->assign('list2',$list2);
		$this->display('app_index.html');
	}
}

?>
